﻿using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using TransferPost.Beans;
using TransferPost.checkpoints;
using TransferPost.Componts;
using TransferPost.util;
using System.Linq;

namespace TransferPost.Forms
{
    [PostFormAttribute(FormName = "208个性化代码检查", FormNo = "002")]
    public partial class frmZtbAllCodeCheck : DockContentEx
    {
        private List<SVNProjectInfo> lstSVNPros = new List<SVNProjectInfo>();

        public frmZtbAllCodeCheck()
        {
            InitializeComponent();
        }

        public frmZtbAllCodeCheck(frmMain frm)
        {
            frm_Parent = frm;

            InitializeComponent();
        }

        /// <summary>
        /// TODO:统一取消
        /// </summary>
        /// <param name="msg"></param>
        private void OutPutBootmMsg(string msg)
        {
            PostContext.Instance.MyLogger.Info(msg);

            frm_Parent.AppendText(string.Format("{0} {1}{2}", DateTime.Now.ToString(), msg, System.Environment.NewLine));
        }


        /// <summary>
        /// 读取Excel，把所有的SVN的结构调整过来
        /// 每个文件夹下放一个配置文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInitExitSvn_Click(object sender, System.EventArgs e)
        {
            // 获取所有文件夹
            string[] arrayAll = Directory.GetDirectories(this.txtDownloadPath.Text);

            if (MessageBox.Show(string.Format("警告！！！将对{0}个文件夹进行重置", arrayAll.Length), "", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                foreach (string strDesPath in arrayAll)
                {
                    string strCfgFilePath = Path.Combine(strDesPath, "pro.json");

                    if (File.Exists(strCfgFilePath))
                    {
                        string strCfgContent = File.ReadAllText(strCfgFilePath);

                        SVNProjectInfo item = Newtonsoft.Json.JsonConvert.DeserializeObject<SVNProjectInfo>(strCfgContent);

                        item.LastUpadateVersion = 0;

                        strCfgContent = Newtonsoft.Json.JsonConvert.SerializeObject(item);

                        File.WriteAllText(strCfgFilePath, strCfgContent);
                    }
                }
                MessageBox.Show("重置成功。");
            }
        }
        private string getCellValue(int i, ICell cell)
        {
            if (cell == null || string.IsNullOrWhiteSpace(cell.StringCellValue) || cell.StringCellValue == "NULL")
            {
                return "";
            }

            return cell.StringCellValue;
        }

        private void resetCache()
        {
            SVNPaths.Clear();
            lstSVNPros.Clear();

            txtErrorSVNInfo.Text = "";
        }

        private void ImportExcel_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Multiselect = false;
            openFileDialog.Title = "请选择文件";
            openFileDialog.Filter = "Excel (*.xlsx;*.xls)|*.xlsx;*.xls";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string excelPath = openFileDialog.FileName;

                OutPutBootmMsg("正在解析Excel..." + excelPath);

                AnalysisExcel(excelPath);
            }
        }

        private void AnalysisExcel(string excelPath)
        {
            resetCache();

            using (FileStream fileStream = new FileStream(excelPath, FileMode.Open, FileAccess.Read))
            {
                IWorkbook workbook = null;
                if (excelPath.EndsWith(".xlsx"))
                {
                    workbook = new XSSFWorkbook(fileStream);
                }
                else
                {
                    workbook = new HSSFWorkbook(fileStream);
                }

                ISheet sheet = workbook.GetSheetAt(0);
                if (sheet == null)
                {
                    OutPutBootmMsg("Excel异常");
                    return;
                }

                //不要有标题
                for (int i = 0; i < sheet.LastRowNum; i++)
                {
                    try
                    {
                        IRow row = sheet.GetRow(i);

                        if (row.GetCell(0) == null)
                            continue;

                        //proguid
                        string proGuid = getCellValue(i, row.GetCell(0));

                        //proguid
                        string proName = getCellValue(i, row.GetCell(1));

                        //svn地址 
                        string svnPath = getCellValue(i, row.GetCell(3));

                        string isZuofei = getCellValue(i, row.GetCell(4));

                        if (isZuofei == "作废")
                        {
                            continue;
                        }

                        if (svnPath.EndsWith("/"))
                        {
                            svnPath = svnPath.Substring(0, svnPath.Length - 1);
                        }
                        if (svnPath.EndsWith("/doc"))
                        {
                            svnPath = svnPath.Substring(0, svnPath.Length - 4);
                        }
                        //SVNPaths.AppendText(svnPath + "\r\n");

                        //string dirPath = svnPath.Substring(svnPath.LastIndexOf('/') + 1);


                        lstSVNPros.Add(new SVNProjectInfo()
                        {
                            ProjectGuid = proGuid,
                            ProjectName = proName,
                            // 默认是没有斜杠的
                            SVNPath = svnPath,
                            DirectoryName = proName
                        }); ;
                    }
                    catch (Exception ex)
                    {
                        OutPutBootmMsg("加载终止：" + ex.Message);
                        return;
                    }

                }

                OutPutBootmMsg("加载完成，共获得有效SVN地址信息为：" + lstSVNPros.Count);
            }

            // 如果有重名的，就直接修改文件夹的名称为项目名称+Guid
            var sanmeSVN = lstSVNPros.GroupBy(x => x.SVNPath).Where(x => x.Count() > 1).ToList();

            if (sanmeSVN.Count > 0)
            {
                MessageBox.Show("有相同SVN地址项目，请手动处理好excel重新导入" + sanmeSVN.First().Key);

                return;
            }

            // 如果有重名的，就直接修改文件夹的名称为项目名称+Guid
            var sanmePro = lstSVNPros.GroupBy(x => x.DirectoryName).Where(x => x.Count() > 1).ToList();

            // 遍历处理
            foreach (var item in sanmePro)
            {
                var lst = lstSVNPros.Where(x => x.DirectoryName == item.Key).ToList();

                for (int i = 0; i < lst.Count(); i++)
                {
                    // 人为搞一把
                    lst[i].DirectoryName += lst[i].ProjectGuid;
                }
            }

            for (int i = 0; i < lstSVNPros.Count; i++)
            {
                SVNProjectInfo item = lstSVNPros[i];

                SVNPaths.AppendText(item.SVNPath + "\r\n");
            }
        }

        private void btnSetIgnore_Click(object sender, EventArgs e)
        {
            //string strIgnores = C_SVNCheck_Point.GetRemotingSVNIgnores();

            //if (strIgnores == "")
            //{
            //    // 默认设置的值
            //    strIgnores = C_SVNCheck_Point.IGN_LST;
            //}

            string strIgnores = C_SVNCheck_Point.IGN_LST;

            C_SVNCheck_Point.SetRegIgnores(strIgnores);

            OutPutBootmMsg(string.Format("已设置忽略项为：{0},{1}", strIgnores, "可以通过SVN右键菜单查看"));

            MessageBox.Show("已设置忽略项为：" + strIgnores);
        }

        private void PrintErrorSVN(string errormsg)
        {
            this.Invoke(new Action(() =>
            {
                this.txtErrorSVNInfo.Text += errormsg + System.Environment.NewLine;
            }));

            OutPutBootmMsg(errormsg);
        }

        private static object obj = new object();

        private SVNProjectInfo Popup(string id)
        {
            lock (obj)
            {
                if (lstSVNPros.Count == 0)
                    return null;
                else
                {
                    SVNProjectInfo pro = lstSVNPros[lstSVNPros.Count - 1];
                    lstSVNPros.RemoveAt(lstSVNPros.Count - 1);

                    OutPutBootmMsg(string.Format("第{2}线程领任务，还剩{0};开始{1}", lstSVNPros.Count, pro.SVNPath, id));

                    return pro;
                }
            }
        }

        List<string> lstFilter = new List<string>();

        string strSearchPattern = "";

        private void Download_Click(object sender, EventArgs e)
        {
            if (txtFilterStr.Text.Equals(""))
            {
                MessageBox.Show("磁盘有限，必须输入过滤项");
                return;
            }
            else
            {
                lstFilter.Clear();

                foreach (string s in txtFilterStr.Text.Split(','))
                {
                    if (string.IsNullOrEmpty(s) || !s.Contains("."))
                        continue;

                    lstFilter.Add(s.Split('.')[1]);

                    strSearchPattern += "--search \"" + s.Trim() + "\" ";
                }
            }

            //读取Excel文件，便利现在的文件夹，进行处理
            if (lstSVNPros.Count == 0)
            {
                OutPutBootmMsg("没有解析到对应的SVN路径.");
                return;
            }

            for (int i = 1; i <= txtThreadNo.Value; i++)
            {
                Thread thread = new Thread(new ParameterizedThreadStart(doJob));

                thread.Start(i);
            }
        }

        private void doJob(object threaid)
        {
            string i_ThreadID = threaid.ToString();

            Label showlbl = panel3.Controls.Find("lblThread" + i_ThreadID, true)[0] as Label;

            bool blnSinglThreadIsOk = true;

            string passStr = "";
            if (!string.IsNullOrWhiteSpace(UserName.Text) && !string.IsNullOrWhiteSpace(Password.Text))
            {
                passStr = "--username " + UserName.Text + " --password " + Password.Text;
            }
            else
            {
                OutPutBootmMsg("请输入账号密码.");
                return;
            }

            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();

            do
            {
                SVNProjectInfo item = Popup(i_ThreadID);

                if (item == null)
                {
                    this.Invoke(new Action(() =>
                    {
                        // 当前状态
                        showlbl.Text = string.Format(" 空闲。 更新已经完成，等待后续操作中...");
                    }));

                    return;
                }

                //for (int i = 0; i < lstSVNPros.Count; i++)
                {
                    blnSinglThreadIsOk = true;

                    stopwatch.Restart();

                    //SVNProjectInfo item = lstSVNPros[i];

                    //svn://192.168.0.51/2010/T09/宿迁工程建设项目网上招标投标系统
                    //if (!item.ProjectName.Contains("兵团公共资源“一体化平台”项目建设工程"))
                    //{
                    //    continue;
                    //}

                    // 当前的SVN地址
                    int i_RemoteVersion = 0;

                    // 要下载的文件清单
                    List<string> lstNeedDownLoadUrl = new List<string>();

                    string strDesPath = Path.Combine(this.txtDownloadPath.Text, item.DirectoryName);

                    //OutPutBootmMsg("开始处理第 " + i.ToString() + " 个:" + item.SVNPath);


                    if (!Directory.Exists(strDesPath))
                    {
                        Directory.CreateDirectory(strDesPath);
                    }

                    #region " 初始化配置信息 "
                    string strCfgFilePath = Path.Combine(strDesPath, "pro.json");

                    if (!File.Exists(strCfgFilePath))
                    {
                        item.InitTime = DateTime.Now;

                        // 上次更新之后的版本号
                        item.LastUpadateVersion = 0;

                        // 10年前的代码就不用管了先
                        item.LastUpdateTime = DateTime.Now.AddYears(-12);

                        string strProJson = Newtonsoft.Json.JsonConvert.SerializeObject(item);

                        File.WriteAllText(strCfgFilePath, strProJson);
                    }
                    else
                    {
                        string strCfgContent = File.ReadAllText(strCfgFilePath);

                        SVNProjectInfo localProInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<SVNProjectInfo>(strCfgContent);

                        localProInfo.LastUpdateTime = DateTime.Now;

                        // 逻辑安全检测
                        if (!item.SVNPath.Equals(localProInfo.SVNPath))
                        {
                            //throw new Exception("配置文件地址与实际文件地址不对称：" + item.SVNPath);

                            PrintErrorSVN(item.SVNPath);

                            // 继续下一个
                            continue;
                        }

                        // 赋值
                        item = localProInfo;
                    }
                    #endregion

                    #region " 获取最新的版本信息 "
                    //

                    //svn info --show-item revision --username zhzhh --password !zhzhh!  svn://192.168.0.51/EpointBid4/CoreCode

                    Process process = new Process();
                    process.StartInfo.FileName = @"svn";
                    process.StartInfo.Arguments = "info --show-item revision " + passStr + " " + item.SVNPath;
                    process.StartInfo.UseShellExecute = false;
                    process.StartInfo.RedirectStandardOutput = true;
                    process.StartInfo.RedirectStandardError = true;
                    process.StartInfo.CreateNoWindow = true;
                    //process.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
                    process.StartInfo.StandardErrorEncoding = System.Text.Encoding.UTF8;
                    process.Start();

                    // 输出提示信息
                    //OutPutBootmMsg(process.StartInfo.Arguments);

                    try
                    {
                        // 正常情况下，只会返回一个int值（版本号），如果不是的就是错的，下面不要执行了，记录错误日志。
                        string reviesion = process.StandardOutput.ReadToEnd();

                        // 当前的版本号，用于存下去的
                        i_RemoteVersion = 0;

                        bool blnConvertRtn = int.TryParse(reviesion, out i_RemoteVersion);

                        if (blnConvertRtn == false)
                        {
                            //PrintErrorSVN(item.SVNPath + "-" + reviesion);
                            throw new Exception(string.Format("获取服务器SVN版本信息失败{0}", item.SVNPath));
                        }
                    }
                    catch (Exception ex)
                    {
                        blnSinglThreadIsOk = false;

                        // 除了自定义异常，还有别的链接异常等
                        OutPutBootmMsg(ex.Message);

                        //
                        PrintErrorSVN(item.SVNPath);

                        // 继续下一个
                        continue;
                    }

                    #endregion

                    // 如果获取到的服务器的最新版本号，跟自己的当地工程比一样，或者更低，则跳过
                    if (i_RemoteVersion == item.LastUpadateVersion)
                    {
                        OutPutBootmMsg(string.Format(">>> {0} 版本号一致：{1}", item.ProjectName, i_RemoteVersion));
                        continue;
                    }
                    else if (i_RemoteVersion < item.LastUpadateVersion)
                    {
                        blnSinglThreadIsOk = false;

                        PrintErrorSVN(item.SVNPath + ">>> 版本号出现异常！：" + i_RemoteVersion);

                        continue;
                    }
                    else
                    {
                        OutPutBootmMsg(string.Format(">>>第{2}线程，{3}： 本机版本为 {0} 服务器版本为 {1}", item.LastUpadateVersion, i_RemoteVersion, i_ThreadID, item.ProjectName));
                    }


                    // add by zhzhh at 
                    // $ svn log -r {2006-11-20}:{2006-11-29} 这个是用来做时间过滤的，
                    // 目前的问题是 SVN List -v 出来的日期看不懂，而且还需要解析，那么这个就很可怕了。
                    // 而且还要研究这个东西的排序是什么，是不是本身有排序的

                    // 因为上面输入了账号密码，这里可以不用了
                    string args = "list -R -v --depth=infinity ";// + passStr + " ";


                    //svn list -R -v --depth=infinity --username zhzhh --password !! --search "*.js" --search "*.cs" --search "*.css" --search "*.aspx" --search "*.java" --search "*.html" --search "*.htm" svn://192.168.0.51/EpointBid4/CoreCode/Trunk
                    //svn list -R -v --depth=infinity --username zhzhh --password !! --search "*.xsd" svn://192.168.0.51/EpointBid4/CoreCode/Trunk

                    args += strSearchPattern + item.SVNPath;

                    // 更新之前先获取最新的全局版本号，并且记录到项目信息中；迭代为上次的更新版本号
                    // 如果发现最新的全局版本号，跟上次的版本一样，则直接跳过，记录日志
                    // 如果发现最新的全局版本号，比上次的小，抛出异常
                    // 如果发现最新的全局版本号，比上次的大，这进入分析
                    //  遍历清单，把最新的版本号的文件要比上次更新的信息大的？

                    process = new Process();
                    process.StartInfo.FileName = @"svn";
                    process.StartInfo.Arguments = args;
                    process.StartInfo.UseShellExecute = false;
                    process.StartInfo.RedirectStandardOutput = true;
                    process.StartInfo.RedirectStandardError = true;
                    process.StartInfo.CreateNoWindow = true;
                    //process.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
                    process.StartInfo.StandardErrorEncoding = System.Text.Encoding.UTF8;
                    process.Start();

                    /*
                     * TODO：佛山的要处理 还有这2个不能更新
                     * svn://192.168.0.51/2010/T04/辽宁建设工程网上招投标运行平台个性化
                     * svn://192.168.0.51/2008/t04/南京市建设工程网上招投标电子商务平台  好像是卡住了
                     */
                    process.OutputDataReceived += (s, e1) =>
                    {
                        if (e1.Data != null)
                        {
                            // 正确和错误的信息都在这里。
                            string str = e1.Data;

                            // 这种肯定是错的，
                            if (str.StartsWith("svn:"))
                            {
                                OutPutBootmMsg(str);

                                blnSinglThreadIsOk = false;

                                PrintErrorSVN(item.SVNPath);
                            }
                            else
                            {
                                // 做字符串判断，不在过滤后缀名的都不要处理了。
                                if (str.Length > 248 || str.Contains("node_modules") || !filterByInputStr(str))
                                {
                                    // 这个是有问题的,
                                    // 暂时不记录日志了。
                                }
                                else
                                {
                                    // 总结的规则，前6位是版本号
                                    // 从第44开始是URL
                                    int intCurrentVersion = 0;

                                    bool blnCVersion = int.TryParse(str.Substring(0, 8).Trim(), out intCurrentVersion);

                                    if (!blnCVersion)
                                    {
                                        // 如果这里出问题了，应该就不记录下载痕迹了
                                        //OutPutBootmMsg("出异常了：" + str);

                                        PrintErrorSVN("出异常了：" + str);

                                        blnSinglThreadIsOk = false;

                                        PrintErrorSVN(item.SVNPath);
                                    }
                                    else
                                    {
                                        if (intCurrentVersion > item.LastUpadateVersion)
                                        {
                                            // 2020年4月13日 从第一个斜杠开始倒推前一个空格。
                                            int i_FirstSplit = str.IndexOf('/');

                                            if (i_FirstSplit > 0)
                                            {
                                                // 说明这个就是个【文件】之类东西

                                                this.Invoke(new Action(() =>
                                                {
                                                    // 当前状态
                                                    showlbl.Text = string.Format(" >>> 第{1}线程遍历 {2} 文件 {0}", lstNeedDownLoadUrl.Count, i_ThreadID, str);
                                                }));

                                                int i_LastSpace = str.Substring(0, i_FirstSplit).LastIndexOf(" ");

                                                lstNeedDownLoadUrl.Add(str.Substring(i_LastSpace + 1));
                                            }
                                            else
                                            {
                                                OutPutBootmMsg("出异常了：" + str);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    };

                    process.BeginOutputReadLine();

                    string error = process.StandardError.ReadToEnd();

                    if (!string.IsNullOrWhiteSpace(error))
                    {
                        OutPutBootmMsg(">>>3-下载出错:" + error);
                    }

                    process.WaitForExit();

                    int index = 0;

                    OutPutBootmMsg(string.Format(" >>> 第{1}线程发现 {2} 需要更新文件个数为 {0}", lstNeedDownLoadUrl.Count, i_ThreadID, item.ProjectName));

                    foreach (var subUrl in lstNeedDownLoadUrl)
                    {
                        index++;

                        //PostContext.Instance.MyLogger.Info(string.Format(" >>> 4 - {0}/{1} - {2}", index, lstNeedDownLoadUrl.Count, subUrl));

                        this.Invoke(new Action(() =>
                        {
                            // 当前状态
                            showlbl.Text = string.Format(" >>> {0}/{1} - {2}", index, lstNeedDownLoadUrl.Count, subUrl);
                        }));

                        // 本地磁盘文件夹，需要先创建好
                        string strDesFilePath = Path.Combine(strDesPath, subUrl);
                        string strDesDirPath = strDesFilePath.Substring(0, strDesFilePath.LastIndexOf("/") + 1);

                        try
                        {
                            if (!Directory.Exists(strDesDirPath))
                            {
                                Directory.CreateDirectory(strDesDirPath);
                            }
                        }
                        catch (Exception)
                        {
                            //OutPutBootmMsg(">>>4-警告警告-创建失败:" + strDesDirPath);
                            PrintErrorSVN(">>>4-警告警告-创建失败:" + strDesDirPath);
                        }


                        args = "export " + item.SVNPath + "/" + subUrl + " " + strDesDirPath;
                        process.StartInfo.Arguments = args;
                        process.StartInfo.RedirectStandardError = false;
                        process.StartInfo.StandardOutputEncoding = null;
                        process.StartInfo.StandardErrorEncoding = null;
                        process.Start();

                        // 如果下载超过了一分钟，就直接跳过记录日志
                        bool IsOk = process.WaitForExit(60 * 1000);

                        if (IsOk == false)
                        {
                            PrintErrorSVN(" >>> 4 - 警告警告 - 下载文件卡住了:" + subUrl);
                        }
                    }

                    this.Invoke(new Action(() =>
                    {
                        // 当前状态
                        showlbl.Text = string.Format(" >>> {0} 下载完成，等待后续操作", item.ProjectName);
                    }));

                    if (blnSinglThreadIsOk)
                    {
                        //OutPutBootmMsg(">>>90-完善JSON信息:");

                        item.LastUpadateVersion = i_RemoteVersion;

                        string strLastSaveProJson = Newtonsoft.Json.JsonConvert.SerializeObject(item);

                        File.WriteAllText(strCfgFilePath, strLastSaveProJson);
                    }

                    OutPutBootmMsg(string.Format(">>> {0} - 共下载{2} -处理用时:{1}", item.ProjectName, stopwatch.Elapsed.TotalSeconds, lstNeedDownLoadUrl.Count));
                }
            } while (true);
        }

        private bool filterByInputStr(string str)
        {
            string strSuffer = str.Substring(str.LastIndexOf(".") + 1);

            if (string.IsNullOrEmpty(strSuffer))
                return false;
            else
            {
                bool blnNeeded = lstFilter.Exists(x => x.Equals(strSuffer));

                if (blnNeeded)
                {
                    //if (str.EndsWith("designer.cs"))
                    //    return false;

                    if (str.Substring(str.Length - 11).Equals("designer.cs"))
                        return false;

                    // 网站先不要
                    if (str.IndexOf("TPFront", StringComparison.OrdinalIgnoreCase) > 0 || str.Contains("EpointWebBuilder") || str.Contains("ShowCase"))
                        return false;

                    // 手机的也不要了
                    if (str.Contains("/Android") || str.Contains("/android"))
                        return false;

                    return true;
                }
                else
                {
                    return false;
                }
            }
        }

        private void btnPBSpDownLoad_Click(object sender, EventArgs e)
        {
            resetCache();

            //svn list svn://192.168.0.51/EpointBid/SubSys_PingBiaoext/trunk

            lstSVNPros.Clear();

            this.txtDownloadPath.Text = "d:\\pbcode";

            string passStr = "";
            if (!string.IsNullOrWhiteSpace(UserName.Text) && !string.IsNullOrWhiteSpace(Password.Text))
            {
                passStr = "--username " + UserName.Text + " --password " + Password.Text;
            }
            else
            {
                OutPutBootmMsg("请输入账号密码.");
                return;
            }

            Process process = new Process();
            process.StartInfo.FileName = @"svn";
            //process.StartInfo.Arguments = "info --show-item revision " + passStr + " " + item.SVNPath;
            process.StartInfo.Arguments = "list svn://192.168.0.51/EpointBid/SubSys_PingBiaoext/trunk";
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.CreateNoWindow = true;
            //process.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
            process.StartInfo.StandardErrorEncoding = System.Text.Encoding.UTF8;
            process.Start();

            process.OutputDataReceived += (s, e1) =>
            {
                if (e1.Data != null)
                {
                    // 正确和错误的信息都在这里。
                    string str = e1.Data;

                    if (str.EndsWith("/"))
                    {

                        string ProName = str.Trim('/');

                        lstSVNPros.Add(new SVNProjectInfo()
                        {
                            ProjectGuid = ProName,
                            ProjectName = ProName,
                            // 默认是没有斜杠的
                            SVNPath = "svn://192.168.0.51/EpointBid/SubSys_PingBiaoext/trunk/" + ProName,
                            DirectoryName = ProName
                        });
                    }
                }

            };

            process.BeginOutputReadLine();

            string error = process.StandardError.ReadToEnd();

            if (!string.IsNullOrWhiteSpace(error))
            {
                OutPutBootmMsg(">>>3-下载出错:" + error);
            }

            process.WaitForExit();

            for (int i = 0; i < lstSVNPros.Count; i++)
            {
                SVNProjectInfo item = lstSVNPros[i];

                SVNPaths.AppendText(item.SVNPath + "\r\n");
            }

            // aaa 
            Download_Click(this, null);
        }

        private void btnXMZ_Click(object sender, EventArgs e)
        {
            resetCache();

            this.txtDownloadPath.Text = "d:\\ywcode";

            AnalysisExcel(@"D:\SVN清单\业务个性化.xls");

            // aaa 
            Download_Click(this, null);
        }

        private void btnBZB_Click(object sender, EventArgs e)
        {
            resetCache();

            this.txtDownloadPath.Text = "d:\\bzbcode";

            AnalysisExcel(@"D:\SVN清单\所有标准版.xls");

            // aaa 
            Download_Click(this, null);
        }
    }
}
